package cn.itcast.hotel.web.controller;

import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.dto.HotelDocDto;
import cn.itcast.hotel.service.IHotelService;
import cn.itcast.hotel.web.result.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * hotel的web层控制器
 *
 * @Author XiaoJiangShi
 * @Date 2022/8/6 20:17
 * @Blog blog.XiaoJiangShi.net/996.mba
 * @Description: hotel的web层控制器
 */
@Slf4j
@RestController
@RequestMapping("/hotel")
public class HotelController {
    @Autowired
    private IHotelService service;

    /**
     * 根据条件分页查询
     * @param hotelDocDto 前端传来的分页数据
     * @return 结果返回对象
     */
    @PostMapping("/list")
    public PageResult<HotelDoc> list(@RequestBody HotelDocDto hotelDocDto) {
        log.info("分页的数据为：[{}]", hotelDocDto.toString());
        return service.listByCondition(hotelDocDto);
    }

    /**
     * 根据条件查询
     * @param hotelDocDto 条件数据
     * @return map对象
     */
    @PostMapping("/filter")
    public Map<String, List<String>> filter(@RequestBody HotelDocDto hotelDocDto) {
        log.info("根据条件查询的数据为：[{}]", hotelDocDto.toString());
        return service.filterByCondition(hotelDocDto);
    }

}

